<template>
<div id="components">

</div>
</template>
<script>
import { mapMutations } from 'vuex'
import {GetUserInfoByjwt} from './Resources/Api'

export default {
    data () {
        return {

        }
    },
    created () {
        this.GetUserInfoByjwt()
    },
    methods: {
        ...mapMutations({
            setUserInfo: `SET_USER_INFO`
        }),
        GetUserInfoByjwt () {
            let url = window.location.href
            let jwt = url.split('jwt')[1].split('=')[1]

            GetUserInfoByjwt({
                jwt: jwt
            }).then(results => {
                if (results.data.StatusCode >= 0) {
                    let userInfo = results.data.Body
                    this.$utils.setLocal('userInfo', userInfo)
                    this.setUserInfo(userInfo)
                    this.$router.push('/ElementRx')
                }
            })
        }
    }
}
</script>
